<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>实验室设备管理系统</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../static/layui/css/layui.css"  media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body style="height: 600px">

<table class="layui-table" id="test" >
<!-- lay-data="{width: 892, height:332, url:'/demo/table/user/', page:true, id:'idTest'}" lay-filter="demo" -->
  <thead>
    <tr>
      <th lay-data="{field:'sort', width:80, sort: true, fixed: left}">序号</th>
      <th lay-data="{field:'kind', width:80}">设备类型</th>
      <th lay-data="{field:'name', width:80, sort: true}">设备名称</th>
      <th lay-data="{field:'id', width:80}">设备编号</th>
      <th lay-data="{field:'room', width:140}">设备所在实验室</th>
      <th lay-data="{field:'teacher', width:80, sort: true}">负责教师</th>
      <th lay-data="{field:'tphone', width:80}">教师电话</th>
      <th lay-data="{field:'state', width:40, sort: true}">状态</th>
      <th lay-data="{fixed: 'right', width:178, toolbar: '#barDemo'}">操作</th>
    </tr>
  </thead>

  <tbody>
    {% block table %}
    {% for equipment in equipments %}
    <tr data-index="0" class="">
    <td data-field="sort">
      <div class="layui-table-cell">{{ forloop.counter }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eKind }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eName }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.id }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eRoom }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eTeacher.tName }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eTeacher.tPhone }}</div>
    </td>
    <td data-field="sort">
      <div class="layui-table-cell">{{ equipment.eState }}</div>
    </td>
    {% block button %}

    <td data-field="10" align="center" data-off="true">
        <div class="layui-table-cell laytable-cell-1-10">
          {% if equipment.eState == '可借' %}
          <a class="borrow layui-btn layui-btn-xs" lay-event="borrow" data-url=borrow?eid={{equipment.id}}>借用</a>
          {% else %}
          <a class="layui-btn layui-btn-disabled layui-btn-xs" >借用</a>
          {% endif %}
        </div>
    </td>
    {% endblock button %}
    </tr>
    {% endfor %}
    {% endblock %}
  </tbody>

</table>

<script src="../../static/layui/layui.js" type="text/javascript"></script>
<script src="../../static/layui/lay/modules/jquery.js" type="text/javascript"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script type="text/javascript">

  layui.use('layer', function(){
    var layer = layui.layer;
    var $ = layui.jquery;
    $(".borrow").click(function() {
      var url = $(this).attr("data-url");
      $.get(url,function(data,status){
        console.log(layer);
        layer.msg(data, {time: 1000}, function() {
          location.href = location.href;
        });
        // console.log(location.href);
        // alert(data);
      });
    });

  });

  layui.use('layer', function(){
    var layer = layui.layer;
    var $ = layui.jquery;
    $(".return").click(function() {
      var url = $(this).attr("data-url");
      $.get(url,function(data,status){
        console.log(layer);
        layer.msg(data, {time: 1000}, function() {
          location.href = location.href;
        });
        // console.log(location.href);
        // alert(data);
      });
    });

  });
</script>
</body>
</html>